package com.mz.ozy.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.mz.ozy.R;
import com.mz.ozy.utils.glideUtils.GlideUtils;


/**
 * @author liucan on 2018/7/4.
 */
public class ImageDialog {

    private Context context;
    private Dialog dialog;
    private String s;


    public ImageDialog(Context context, String s) {
        this.context = context;
        this.s = s;
    }

    public ImageDialog builder() {
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_select_photo, null);
        dialog = new Dialog(context, R.style.dialog_pay_theme);

        Window window = dialog.getWindow();
        window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        window.setContentView(view);//设置弹框布局
        ImageView imageVisi = view.findViewById(R.id.image_visi);
        ImageView iamgeDetele = view.findViewById(R.id.iamge_detele);
        GlideUtils.loadImg(context, imageVisi, s);
        iamgeDetele.setOnClickListener(v -> dialog.cancel());
        imageVisi.setOnClickListener(view1 -> dialog.cancel());

        dialog.setCanceledOnTouchOutside(true);

        return this;
    }

    public void show() {
        if (dialog != null) {
            dialog.show();
        }
    }

    public void cancle() {
        if (dialog != null) {
            dialog.cancel();
        }
    }


}